<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue-2.5.js"></script>
</head>
<body>
    <div id="app">
        <p>总数 :{{total}}</p>
        <my-component v-model="total"></my-component>
        <button @click="handleReduce"></button>
    </div>
    <script>
        Vue.component('my-component',{
            props:['value'],
            template:`<input :value="value" @input="updateValue">-1</input>`,
            methods: {
                updateValue:function (evt) {
                    this.$emit('input',evt.target.value)
                }
            },
        })

        let app = new Vue({
            el:'#app',
            data:{
                total:0
            },
            methods:{
                handleReduce:function() {
                    this.total--;
                }
            }

        })
    </script>
</body>
</html>